package com.ruoyi.electronicFence.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.electronicFence.domain.bo.TEfControllerBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.electronicFence.domain.TEfController;
import com.ruoyi.electronicFence.service.ITEfControllerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 控制器信息Controller
 *
 * @author sxygsj
 * @date 2024-06-11
 */
@RestController
@RequestMapping("/electronicFence/controller")
public class TEfControllerController extends BaseController
{

    private final ITEfControllerService tEfControllerService;

    @Autowired
    public TEfControllerController(ITEfControllerService tEfControllerService) {
        this.tEfControllerService = tEfControllerService;
    }

    /**
     * 查询控制器信息列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:controller:list')")
    @GetMapping("/list")
    public TableDataInfo list(TEfController tEfController)
    {
        startPage();
        List<TEfController> list = tEfControllerService.selectTEfControllerList(tEfController);
        return getDataTable(list);
    }

    /**
     * 查询控制器信息列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:controller:list')")
    @GetMapping("/with-device-info/list")
    public TableDataInfo withDeviceInfoList(TEfControllerBO tEfControllerBO)
    {
        startPage();
        List<TEfController> list = tEfControllerService.withDeviceInfoList(tEfControllerBO);
        return getDataTable(list);
    }

    /**
     * 导出控制器信息列表
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:controller:export')")
    @Log(title = "控制器信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TEfController tEfController)
    {
        List<TEfController> list = tEfControllerService.selectTEfControllerList(tEfController);
        ExcelUtil<TEfController> util = new ExcelUtil<TEfController>(TEfController.class);
        util.exportExcel(response, list, "控制器信息数据");
    }

    /**
     * 获取控制器信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:controller:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tEfControllerService.selectTEfControllerById(id));
    }

    /**
     * 新增控制器信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:controller:add')")
    @Log(title = "控制器信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TEfController tEfController)
    {
        return toAjax(tEfControllerService.insertTEfController(tEfController));
    }

    /**
     * 修改控制器信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:controller:edit')")
    @Log(title = "控制器信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TEfController tEfController)
    {
        return toAjax(tEfControllerService.updateTEfController(tEfController));
    }

    /**
     * 删除控制器信息
     */
    //@PreAuthorize("@ss.hasPermi('electronicFence:controller:remove')")
    @Log(title = "控制器信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tEfControllerService.deleteTEfControllerByIds(ids));
    }
}
